<%@page import="multiface.kooper.jpa.*"%>
<%@page import="javax.persistence.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("KooperPU");
    EntityManager em = emf.createEntityManager();
    User us = (User) session.getAttribute("user");
    User u = em.find(User.class, us.getId());
    em.refresh(u);
%>
<html>
    <jsp:include flush="true" page="import.jsp"></jsp:include>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Post</title>
    </head>
    <body>
        <jsp:include flush="true" page="header.jsp"></jsp:include>
        <div id="container">
            <div id="wrapper">
                <jsp:include flush="true" page="left.jsp"></jsp:include>

                    <div id="center" class="center">
                    <%
                        for (Post p : u.getPostList()) {
                            out.print("<div class=\"post\">");
                            out.print("<div class=\"post-title\">" + p.getTitle() + "</div>");
                            out.print("<div class=\"post-text\">" + p.getText() + "</div>");
                            out.print("</div>");
                        }

                        em.close();
                        emf.close();
                    %>
                </div>
            </div>
        </div>
        <jsp:include flush="true" page="footer.jsp"></jsp:include>
    </body>
</html>
